# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 519
n 519(None)[self.eventhandler = eventhandler
]:
	i: 404(t), 509()
	o: 

nname: 509
n 509(None)[]:
	i: 404(f)
	o: 519()

nname: 404
n 404(eventhandler)[self.special_chars = self.special_char_list[0]
self.action_buttons = buttons
self.button_ranges = [self.alphabet, self.special_chars, buttons]
self._uppercase_mode = False
self._text_cursor_pos = len(self.text)
self._reset_selection()
self.change_special_char(0)
]:
	i: 362(AL), 403()
	o: 509(f), 519(t)

nname: 403
n 403(None)[]:
	i: 365(AF), 372()
	o: 404()

nname: 372
n 372(None)[for special_char in special_chars:
self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
]:
	i: 365(for)
	o: 403()

nname: 365
n 365(None)[]:
	i: 362(loop)
	o: 372(for), 403(AF)

nname: 362
n 362(None)[]:
	i: 348(), 361()
	o: 365(loop), 404(AL)

nname: 361
n 361(None)[]:
	i: 300(t)
	o: 362()

nname: 348
n 348(None)[special_chars = [special_chars]
]:
	i: 300(f)
	o: 362()

nname: 300
n 300(isinstance(special_chars, (list, tuple)))[self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
self.special_char_list = []
]:
	i: 274(AL), 299()
	o: 348(f), 361(t)

nname: 299
n 299(None)[]:
	i: 277(AF), 284()
	o: 300()

nname: 284
n 284(None)[for but in buttons:
but.type = 'action'
]:
	i: 277(for)
	o: 299()

nname: 277
n 277(None)[]:
	i: 274(loop)
	o: 284(for), 299(AF)

nname: 274
n 274(None)[]:
	i: 243(), 273()
	o: 277(loop), 300(AL)

nname: 273
n 273(None)[]:
	i: 51(t)
	o: 274()

nname: 243
n 243(None)[buttons[3].connect(confirm_action, self)
buttons[4].connect(self.hide)
]:
	i: 66(t), 236()
	o: 274()

nname: 236
n 236(None)[]:
	i: 66(f)
	o: 243()

nname: 66
n 66(confirm_action)[buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
buttons[0].connect(partial(self.change_special_char, -1))
buttons[1].connect(self.change_special_char)
buttons[2].connect(self.delete_char)
]:
	i: 51(f)
	o: 236(f), 243(t)

nname: 51
n 51(buttons)[self.columns = columns
]:
	i: 40(), 50()
	o: 66(f), 273(t)

nname: 50
n 50(None)[]:
	i: 0(t)
	o: 51()

nname: 40
n 40(None)[columns = 12
]:
	i: 0(f)
	o: 51()

nname: 0
n 0(columns)[ConfirmWindow.__init__(self, text=text, buttons=[])
self.title = title
]:
	i: 
	o: 40(f), 50(t)

nname: 519
n 519(None)[self.eventhandler = eventhandler
]:
	i: 403(t)
	o: 

nname: 403
n 403(None)[self.special_chars = self.special_char_list[0]
self.action_buttons = buttons
self.button_ranges = [self.alphabet, self.special_chars, buttons]
self._uppercase_mode = False
self._text_cursor_pos = len(self.text)
self._reset_selection()
self.change_special_char(0)
if not eventhandler:
	pass
]:
	i: 365()
	o: 519()

nname: 365
n 365(None)[for special_char in special_chars:
	self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
]:
	i: 300(loop)
	o: 403()

nname: 300
n 300(None)[self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
self.special_char_list = []
if not isinstance(special_chars, (list, tuple)):
	special_chars = [special_chars]
]:
	i: 284()
	o: 365(loop)

nname: 284
n 284(None)[for but in buttons:
	but.type = 'action'
]:
	i: 274(for)
	o: 300()

nname: 274
n 274(None)[]:
	i: 66(), 0(t)
	o: 284(for)

nname: 66
n 66(None)[buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
buttons[0].connect(partial(self.change_special_char, -1))
buttons[1].connect(self.change_special_char)
buttons[2].connect(self.delete_char)
if not confirm_action:
	pass
buttons[3].connect(confirm_action, self)
buttons[4].connect(self.hide)
]:
	i: 0(f)
	o: 274()

nname: 0
n 0(buttons)[ConfirmWindow.__init__(self, text=text, buttons=[])
self.title = title
if not columns:
	columns = 12
self.columns = columns
]:
	i: 
	o: 66(f), 274(t)

nname: 519
n 519(None)[self.eventhandler = eventhandler
]:
	i: 365(t)
	o: 

nname: 365
n 365(None)[for special_char in special_chars:
	self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
self.special_chars = self.special_char_list[0]
self.action_buttons = buttons
self.button_ranges = [self.alphabet, self.special_chars, buttons]
self._uppercase_mode = False
self._text_cursor_pos = len(self.text)
self._reset_selection()
self.change_special_char(0)
if not eventhandler:
	pass
]:
	i: 284(loop)
	o: 519()

nname: 284
n 284(None)[for but in buttons:
	but.type = 'action'
self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
self.special_char_list = []
if not isinstance(special_chars, (list, tuple)):
	special_chars = [special_chars]
]:
	i: 0(for)
	o: 365(loop)

nname: 0
n 0(None)[ConfirmWindow.__init__(self, text=text, buttons=[])
self.title = title
if not columns:
	columns = 12
self.columns = columns
if not buttons:
	buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
	buttons[0].connect(partial(self.change_special_char, -1))
	buttons[1].connect(self.change_special_char)
	buttons[2].connect(self.delete_char)
	if not confirm_action:
		pass
	buttons[3].connect(confirm_action, self)
	buttons[4].connect(self.hide)
]:
	i: 
	o: 284(for)

nname: 365
n 365(None)[for special_char in special_chars:
	self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
self.special_chars = self.special_char_list[0]
self.action_buttons = buttons
self.button_ranges = [self.alphabet, self.special_chars, buttons]
self._uppercase_mode = False
self._text_cursor_pos = len(self.text)
self._reset_selection()
self.change_special_char(0)
if not eventhandler:
	pass
self.eventhandler = eventhandler
]:
	i: 0(loop)
	o: 

nname: 0
n 0(None)[ConfirmWindow.__init__(self, text=text, buttons=[])
self.title = title
if not columns:
	columns = 12
self.columns = columns
if not buttons:
	buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
	buttons[0].connect(partial(self.change_special_char, -1))
	buttons[1].connect(self.change_special_char)
	buttons[2].connect(self.delete_char)
	if not confirm_action:
		pass
	buttons[3].connect(confirm_action, self)
	buttons[4].connect(self.hide)
for but in buttons:
	but.type = 'action'
self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
self.special_char_list = []
if not isinstance(special_chars, (list, tuple)):
	special_chars = [special_chars]
]:
	i: 
	o: 365(loop)

nname: 0
n 0(None)[ConfirmWindow.__init__(self, text=text, buttons=[])
self.title = title
if not columns:
	columns = 12
self.columns = columns
if not buttons:
	buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
	buttons[0].connect(partial(self.change_special_char, -1))
	buttons[1].connect(self.change_special_char)
	buttons[2].connect(self.delete_char)
	if not confirm_action:
		pass
	buttons[3].connect(confirm_action, self)
	buttons[4].connect(self.hide)
for but in buttons:
	but.type = 'action'
self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
self.special_char_list = []
if not isinstance(special_chars, (list, tuple)):
	special_chars = [special_chars]
for special_char in special_chars:
	self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
self.special_chars = self.special_char_list[0]
self.action_buttons = buttons
self.button_ranges = [self.alphabet, self.special_chars, buttons]
self._uppercase_mode = False
self._text_cursor_pos = len(self.text)
self._reset_selection()
self.change_special_char(0)
if not eventhandler:
	pass
self.eventhandler = eventhandler
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7736e8c>}
nname: 0
n 0(None)[sc_len = max(<genexpr>(self.special_char_list))
return sc_len + len(self.alphabet)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a6ec>}
nname: 0
n 0(None)[return self._button_ranges
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a3ac>}
nname: 49
n 49(None)[del _[1]
for self.buttons in b_range:
]:
	i: 0(AF), 46()
	o: 

nname: 46
n 46(None)[]:
	i: 23(AF), 33()
	o: 49()

nname: 33
n 33(None)[for but in row:
]:
	i: 23(for)
	o: 46()

nname: 23
n 23(None)[for row in b_range:
]:
	i: 0(for)
	o: 33(for), 46(AF)

nname: 0
n 0(None)[self._button_ranges = b_range
]:
	i: 
	o: 23(for), 49(AF)

nname: 49
n 49(None)[del _[1]
for self.buttons in b_range:
]:
	i: 0(AF), 23(AF), 33()
	o: 

nname: 33
n 33(None)[for but in row:
]:
	i: 23(for)
	o: 49()

nname: 23
n 23(None)[for row in b_range:
]:
	i: 0(for)
	o: 33(for), 49(AF)

nname: 0
n 0(None)[self._button_ranges = b_range
]:
	i: 
	o: 23(for), 49(AF)

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a94c>, 33: <unpyclib.structure.node instance at 0xb772a76c>, 49: <unpyclib.structure.node instance at 0xb772a6ac>, 23: <unpyclib.structure.node instance at 0xb772a5ec>}
nname: 67
n 67(None)[return ret
]:
	i: 0(AL), 66()
	o: 

nname: 66
n 66(None)[]:
	i: 9(AF), 16()
	o: 67()

nname: 16
n 16(None)[for char in char_string:
but = Button(char, False)
but.connect(self.insert_char)
ret.append(but)
]:
	i: 9(for)
	o: 66()

nname: 9
n 9(None)[]:
	i: 0(loop)
	o: 16(for), 66(AF)

nname: 0
n 0(None)[ret = []
]:
	i: 
	o: 9(loop), 67(AL)

nname: 67
n 67(None)[return ret
]:
	i: 16()
	o: 

nname: 16
n 16(None)[for char in char_string:
	but = Button(char, False)
	but.connect(self.insert_char)
	ret.append(but)
]:
	i: 0(for)
	o: 67()

nname: 0
n 0(None)[ret = []
]:
	i: 
	o: 16(for)

nname: 67
n 67(None)[return ret
]:
	i: 0()
	o: 

nname: 0
n 0(None)[ret = []
for char in char_string:
	but = Button(char, False)
	but.connect(self.insert_char)
	ret.append(but)
]:
	i: 
	o: 67()

nname: 0
n 0(None)[ret = []
for char in char_string:
	but = Button(char, False)
	but.connect(self.insert_char)
	ret.append(but)
return ret
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a76c>}
nname: 0
n 0(None)[log.warning('Changing characters case is not supported anymore !')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a48c>}
nname: 224
n 224(None)[self.button_ranges = [self.alphabet, self.special_chars, self.action_buttons]
self.action_buttons[0].name = ''.join(<genexpr>(old_list[:4])) + ' <'
self.action_buttons[1].name = '> ' + ''.join(<genexpr>(new_list[:4]))
]:
	i: 139(), 189(), 206()
	o: 

nname: 206
n 206(None)[self.special_chars = chars_list[actual_idx + sense]
]:
	i: 156&169(f)
	o: 224()

nname: 189
n 189(None)[self.special_chars = chars_list[-1]
]:
	i: 156&169(t)
	o: 224()

nname: 156&169
n 156&169(sense < 0 and self.special_chars == chars_list[0])[]:
	i: 0&119(f)
	o: 189(t), 206(f)

nname: 139
n 139(None)[self.special_chars = chars_list[0]
]:
	i: 0&119(t)
	o: 224()

nname: 0&119
n 0&119(sense > 0 and self.special_chars == chars_list[-1])[sense = max(-1, min(1, sense))
chars_list = self.special_char_list
actual_idx = chars_list.index(self.special_chars)
old_list = chars_list[(actual_idx + sense - 1) % len(chars_list)]
new_list = chars_list[(actual_idx + sense + 1) % len(chars_list)]
]:
	i: 
	o: 139(t), 156&169(f)

nname: 0&119
n 0&119(None)[sense = max(-1, min(1, sense))
chars_list = self.special_char_list
actual_idx = chars_list.index(self.special_chars)
old_list = chars_list[(actual_idx + sense - 1) % len(chars_list)]
new_list = chars_list[(actual_idx + sense + 1) % len(chars_list)]
if sense > 0 and self.special_chars == chars_list[-1]:
	self.special_chars = chars_list[0]
else:
	if sense < 0 and self.special_chars == chars_list[0]:
		self.special_chars = chars_list[-1]
	else:
		self.special_chars = chars_list[actual_idx + sense]
self.button_ranges = [self.alphabet, self.special_chars, self.action_buttons]
self.action_buttons[0].name = ''.join(<genexpr>(old_list[:4])) + ' <'
self.action_buttons[1].name = '> ' + ''.join(<genexpr>(new_list[:4]))
]:
	i: 
	o: 

self.nodes: {'0&119': <unpyclib.structure.node instance at 0xb773beac>}
nname: 72
n 72(None)[]:
	i: 15(), 71()
	o: 

nname: 71
n 71(None)[]:
	i: 0(f)
	o: 72()

nname: 15
n 15(None)[self.text = self.text[:self._text_cursor_pos - 1] + self.text[self._text_cursor_pos:]
self._text_cursor_pos -= 1
]:
	i: 0(t)
	o: 72()

nname: 0
n 0(self._text_cursor_pos > 0)[]:
	i: 
	o: 15(t), 71(f)

nname: 0
n 0(None)[if self._text_cursor_pos > 0:
	self.text = self.text[:self._text_cursor_pos - 1] + self.text[self._text_cursor_pos:]
	self._text_cursor_pos -= 1
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a6ac>}
nname: 92
n 92(None)[self._text_cursor_pos += 1
]:
	i: 27(), 68()
	o: 

nname: 68
n 68(None)[self.text = char + self.text[self._text_cursor_pos:]
]:
	i: 0(f)
	o: 92()

nname: 27
n 27(None)[self.text = self.text[:self._text_cursor_pos] + char + self.text[self._text_cursor_pos:]
]:
	i: 0(t)
	o: 92()

nname: 0
n 0(self._text_cursor_pos > 0)[char = self.selected.name
]:
	i: 
	o: 27(t), 68(f)

nname: 0
n 0(None)[char = self.selected.name
if self._text_cursor_pos > 0:
	self.text = self.text[:self._text_cursor_pos] + char + self.text[self._text_cursor_pos:]
else:
	self.text = char + self.text[self._text_cursor_pos:]
self._text_cursor_pos += 1
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772a8ac>}
nname: 6
n 6(None)[type = 'keyboard'
def __init__(self, title='', text='', buttons=None, confirm_action=None, alphabet='', special_chars=latin_map, columns=None, eventhandler=None):
	ConfirmWindow.__init__(self, text=text, buttons=[])
	self.title = title
	if not columns:
		columns = 12
	self.columns = columns
	if not buttons:
		buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
		buttons[0].connect(partial(self.change_special_char, -1))
		buttons[1].connect(self.change_special_char)
		buttons[2].connect(self.delete_char)
		if not confirm_action:
			pass
		buttons[3].connect(confirm_action, self)
		buttons[4].connect(self.hide)
	for but in buttons:
		but.type = 'action'
	self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
	self.special_char_list = []
	if not isinstance(special_chars, (list, tuple)):
		special_chars = [special_chars]
	for special_char in special_chars:
		self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
	self.special_chars = self.special_char_list[0]
	self.action_buttons = buttons
	self.button_ranges = [self.alphabet, self.special_chars, buttons]
	self._uppercase_mode = False
	self._text_cursor_pos = len(self.text)
	self._reset_selection()
	self.change_special_char(0)
	if not eventhandler:
		pass
	self.eventhandler = eventhandler

def get_max_keys_number(self):
	sc_len = max(<genexpr>(self.special_char_list))
	return sc_len + len(self.alphabet)

def _get_button_ranges(self):
	return self._button_ranges

def _set_button_ranges(self, b_range):
	self._button_ranges = b_range

button_ranges = property(_get_button_ranges, _set_button_ranges)
del _get_button_ranges
del _set_button_ranges
def _KeyboardWindow__mk_text_button_list(self, char_string):
	ret = []
	for char in char_string:
		but = Button(char, False)
		but.connect(self.insert_char)
		ret.append(but)
	return ret

def change_char_case(self):
	log.warning('Changing characters case is not supported anymore !')

def change_special_char(self, sense=1):
	sense = max(-1, min(1, sense))
	chars_list = self.special_char_list
	actual_idx = chars_list.index(self.special_chars)
	old_list = chars_list[(actual_idx + sense - 1) % len(chars_list)]
	new_list = chars_list[(actual_idx + sense + 1) % len(chars_list)]
	if sense > 0 and self.special_chars == chars_list[-1]:
		self.special_chars = chars_list[0]
	else:
		if sense < 0 and self.special_chars == chars_list[0]:
			self.special_chars = chars_list[-1]
		else:
			self.special_chars = chars_list[actual_idx + sense]
	self.button_ranges = [self.alphabet, self.special_chars, self.action_buttons]
	self.action_buttons[0].name = ''.join(<genexpr>(old_list[:4])) + ' <'
	self.action_buttons[1].name = '> ' + ''.join(<genexpr>(new_list[:4]))

def delete_char(self):
	if self._text_cursor_pos > 0:
		self.text = self.text[:self._text_cursor_pos - 1] + self.text[self._text_cursor_pos:]
		self._text_cursor_pos -= 1

def insert_char(self):
	char = self.selected.name
	if self._text_cursor_pos > 0:
		self.text = self.text[:self._text_cursor_pos] + char + self.text[self._text_cursor_pos:]
	else:
		self.text = char + self.text[self._text_cursor_pos:]
	self._text_cursor_pos += 1

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb772ec8c>}
nname: 256
n 256(None)[KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
return None
]:
	i: 210(t), 246()
	o: 

nname: 246
n 246(None)[]:
	i: 210(f)
	o: 256()

nname: 210
n 210(eventhandler)[]:
	i: 184(AL), 209()
	o: 246(f), 256(t)

nname: 209
n 209(None)[]:
	i: 187(AF), 194()
	o: 210()

nname: 194
n 194(None)[for but in buttons:
but.type = 'action'
]:
	i: 187(for)
	o: 209()

nname: 187
n 187(None)[]:
	i: 184(loop)
	o: 194(for), 209(AF)

nname: 184
n 184(None)[]:
	i: 24(), 183()
	o: 187(loop), 210(AL)

nname: 183
n 183(None)[]:
	i: 0(t)
	o: 184()

nname: 24
n 24(None)[buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
buttons[0].connect(partial(self.change_special_char, -1))
buttons[1].connect(self.change_special_char)
buttons[2].connect(self.delete_char)
buttons[3].connect(self.hide)
]:
	i: 0(f)
	o: 184()

nname: 0
n 0(buttons)[self._insert_char_action = insert_char_action
self._delete_char_action = delete_char_action
]:
	i: 
	o: 24(f), 183(t)

nname: 256
n 256(None)[KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
return None
]:
	i: 209(t)
	o: 

nname: 209
n 209(None)[if not eventhandler:
	pass
]:
	i: 187()
	o: 256()

nname: 187
n 187(None)[for but in buttons:
	but.type = 'action'
]:
	i: 0(loop)
	o: 209()

nname: 0
n 0(None)[self._insert_char_action = insert_char_action
self._delete_char_action = delete_char_action
if not buttons:
	buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
	buttons[0].connect(partial(self.change_special_char, -1))
	buttons[1].connect(self.change_special_char)
	buttons[2].connect(self.delete_char)
	buttons[3].connect(self.hide)
]:
	i: 
	o: 187(loop)

nname: 209
n 209(None)[if not eventhandler:
	pass
KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
return None
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self._insert_char_action = insert_char_action
self._delete_char_action = delete_char_action
if not buttons:
	buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
	buttons[0].connect(partial(self.change_special_char, -1))
	buttons[1].connect(self.change_special_char)
	buttons[2].connect(self.delete_char)
	buttons[3].connect(self.hide)
for but in buttons:
	but.type = 'action'
]:
	i: 
	o: 209()

nname: 0
n 0(None)[self._insert_char_action = insert_char_action
self._delete_char_action = delete_char_action
if not buttons:
	buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
	buttons[0].connect(partial(self.change_special_char, -1))
	buttons[1].connect(self.change_special_char)
	buttons[2].connect(self.delete_char)
	buttons[3].connect(self.hide)
for but in buttons:
	but.type = 'action'
if not eventhandler:
	pass
KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb773b54c>}
nname: 24
n 24(None)[]:
	i: 9(), 23()
	o: 

nname: 23
n 23(None)[]:
	i: 0(f)
	o: 24()

nname: 9
n 9(None)[self._delete_char_action()
]:
	i: 0(t)
	o: 24()

nname: 0
n 0(self._delete_char_action)[]:
	i: 
	o: 9(t), 23(f)

nname: 0
n 0(None)[if self._delete_char_action:
	self._delete_char_action()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772ee0c>}
nname: 33
n 33(None)[]:
	i: 9(), 32()
	o: 

nname: 32
n 32(None)[]:
	i: 0(f)
	o: 33()

nname: 9
n 9(None)[self._insert_char_action(self.selected.name)
]:
	i: 0(t)
	o: 33()

nname: 0
n 0(self._insert_char_action)[]:
	i: 
	o: 9(t), 32(f)

nname: 0
n 0(None)[if self._insert_char_action:
	self._insert_char_action(self.selected.name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772edac>}
nname: 6
n 6(None)[type = 'silent_keyboard'
def __init__(self, buttons=None, alphabet='', special_chars=latin_map, insert_char_action=None, delete_char_action=None, columns=None, eventhandler=None):
	self._insert_char_action = insert_char_action
	self._delete_char_action = delete_char_action
	if not buttons:
		buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
		buttons[0].connect(partial(self.change_special_char, -1))
		buttons[1].connect(self.change_special_char)
		buttons[2].connect(self.delete_char)
		buttons[3].connect(self.hide)
	for but in buttons:
		but.type = 'action'
	if not eventhandler:
		pass
	KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
	return None

def delete_char(self):
	if self._delete_char_action:
		self._delete_char_action()

def insert_char(self):
	if self._insert_char_action:
		self._insert_char_action(self.selected.name)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb772efec>}
nname: 0
n 0(None)[return kbd.hide()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77366ac>}
nname: 177
n 177(None)[buttons[1].connect(confirm_action, self)
buttons[2].connect(self.hide)
KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons)
]:
	i: 74(t), 170()
	o: 

nname: 170
n 170(None)[]:
	i: 74(f)
	o: 177()

nname: 74
n 74(confirm_action)[buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
buttons[0].connect(self.delete_char)
]:
	i: 21(), 59(), 73()
	o: 170(f), 177(t)

nname: 73
n 73(None)[]:
	i: 37(f)
	o: 74()

nname: 59
n 59(None)[text = '%.2f' % value
]:
	i: 37(t)
	o: 74()

nname: 37
n 37(isinstance(value, (float, long)))[]:
	i: 0(f)
	o: 59(t), 73(f)

nname: 21
n 21(None)[text = str(value)
]:
	i: 0(t)
	o: 74()

nname: 0
n 0(isinstance(value, int))[text = value
]:
	i: 
	o: 21(t), 37(f)

nname: 177
n 177(None)[buttons[1].connect(confirm_action, self)
buttons[2].connect(self.hide)
KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons)
]:
	i: 0(t)
	o: 

nname: 0
n 0(None)[text = value
if isinstance(value, int):
	text = str(value)
else:
	if isinstance(value, (float, long)):
		text = '%.2f' % value
buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
buttons[0].connect(self.delete_char)
if not confirm_action:
	pass
]:
	i: 
	o: 177()

nname: 0
n 0(None)[text = value
if isinstance(value, int):
	text = str(value)
else:
	if isinstance(value, (float, long)):
		text = '%.2f' % value
buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
buttons[0].connect(self.delete_char)
if not confirm_action:
	pass
buttons[1].connect(confirm_action, self)
buttons[2].connect(self.hide)
KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb773bd0c>}
nname: 0
n 0(None)[return self._text.replace(' ', '')
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772edac>}
nname: 0
n 0(None)[return int(self._NumericKeyboardWindow__stripped_val())
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772eacc>}
nname: 0
n 0(None)[return float(self._NumericKeyboardWindow__stripped_val())
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772eb0c>}
nname: 6
n 6(None)[type = 'numeric_keyboard'
def __init__(self, title='Enter number:', value=0, confirm_action=None, columns=3):
	text = value
	if isinstance(value, int):
		text = str(value)
	else:
		if isinstance(value, (float, long)):
			text = '%.2f' % value
	buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
	buttons[0].connect(self.delete_char)
	if not confirm_action:
		pass
	buttons[1].connect(confirm_action, self)
	buttons[2].connect(self.hide)
	KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons)

def _NumericKeyboardWindow__stripped_val(self):
	return self._text.replace(' ', '')

def get_int(self):
	return int(self._NumericKeyboardWindow__stripped_val())

def get_float(self):
	return float(self._NumericKeyboardWindow__stripped_val())

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb772eb4c>}
nname: 0
n 0(None)[KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, eventhandler=SearchKeyboardEventHandler(self))
self.search_menu = search_menu
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772ec4c>}
nname: 37
n 37(None)[]:
	i: 19(), 36()
	o: 

nname: 36
n 36(None)[]:
	i: 0(f)
	o: 37()

nname: 19
n 19(None)[self.search_menu.hide()
]:
	i: 0(t)
	o: 37()

nname: 0
n 0(hide_search_menu)[KeyboardWindow.hide(self)
]:
	i: 
	o: 19(t), 36(f)

nname: 0
n 0(None)[KeyboardWindow.hide(self)
if hide_search_menu:
	self.search_menu.hide()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb772ec2c>}
nname: 6
n 6(None)[type = 'keyboard'
def __init__(self, title='Search', text='', confirm_action=None, search_menu=None):
	KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, eventhandler=SearchKeyboardEventHandler(self))
	self.search_menu = search_menu

def hide(self, hide_search_menu=False):
	KeyboardWindow.hide(self)
	if hide_search_menu:
		self.search_menu.hide()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb772e94c>}
nname: 0
n 0(None)[return kbd.hide()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb773b26c>}
nname: 123
n 123(None)[buttons[2].connect(confirm_action, self)
alphabet = '0123456789ABCDEF'
KeyboardWindow.__init__(self, title=title, text=text, buttons=buttons, alphabet=alphabet, special_chars=['', ''])
]:
	i: 0(t), 116()
	o: 

nname: 116
n 116(None)[]:
	i: 0(f)
	o: 123()

nname: 0
n 0(confirm_action)[buttons = [Button(_('Exit'), False), Button(_('Delete'), False), Button(_('OK'), True)]
buttons[0].connect(self.hide)
buttons[1].connect(self.delete_char)
]:
	i: 
	o: 116(f), 123(t)

nname: 0
n 0(None)[buttons = [Button(_('Exit'), False), Button(_('Delete'), False), Button(_('OK'), True)]
buttons[0].connect(self.hide)
buttons[1].connect(self.delete_char)
if not confirm_action:
	pass
buttons[2].connect(confirm_action, self)
alphabet = '0123456789ABCDEF'
KeyboardWindow.__init__(self, title=title, text=text, buttons=buttons, alphabet=alphabet, special_chars=['', ''])
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb773ba0c>}
nname: 6
n 6(None)[type = 'hexa_keyboard'
def __init__(self, title='Search', text='', confirm_action=None):
	buttons = [Button(_('Exit'), False), Button(_('Delete'), False), Button(_('OK'), True)]
	buttons[0].connect(self.hide)
	buttons[1].connect(self.delete_char)
	if not confirm_action:
		pass
	buttons[2].connect(confirm_action, self)
	alphabet = '0123456789ABCDEF'
	KeyboardWindow.__init__(self, title=title, text=text, buttons=buttons, alphabet=alphabet, special_chars=['', ''])

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb772e5cc>}
nname: 0
n 0(None)[from __future__ import absolute_import
__all__ = ['KeyboardWindow', 'NumericKeyboardWindow', 'SearchKeyboardWindow', 'HexaKeyboardWindow', 'SilentKeyboardWindow']
from .confirmwindow import ConfirmWindow
from .core import Button
from pygui.eventmanager.windows import KeyboardEventHandler, SearchKeyboardEventHandler, SilentKeyboardEventHandler
from peewee.debug import GET_LOGGER
from functools import partial
log = GET_LOGGER(__name__)
latin_map = [[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u'[', u'\\', u']', u'^', u'_', u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u':', u';', u'<', u'=', u'>', u'?', u' '], [u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'{', u'|', u'}', u'~', u'@', u'!', u'"', u'#', u'$', u'%', u'&', u"'", u'(', u')', u'*', u'+', u',', u'-', u'.', u'/', u'`', u' '], [u'\xc1', u'\xc2', u'\xc3', u'\xc4', u'\xc5', u'\xc6', u'\xc7', u'\xc8', u'\xc9', u'\xca', u'\xcb', u'\xcc', u'\xcd', u'\xce', u'\xcf', u'\xd0', u'\xd1', u'\xd2', u'\xd3', u'\xd4', u'\xd5', u'\xd6', u'\xd7', u'\xd8', u'\xd9', u'\xda', u'\xdb', u'\xdc', u'\xdd', u'\xde', u'\xdf', u'\xe0', u'\xe1', u'\xe2', u'\xe3', u'\xe4', u'\xe5', u'\xe6', u'\xe7', u'\xe8', u'\xe9', u'\xea', u'\xeb', u'\xec', u'\xed', u'\xee', u'\xef', u'\xf0'], [u'\xf1', u'\xf2', u'\xf3', u'\xf4', u'\xf5', u'\xf6', u'\xf7', u'\xf8', u'\xf9', u'\xfa', u'\xfb', u'\xfc', u'\xfd', u'\xfe', u'\xff', u'\xa1', u'\xa2', u'\xa3', u'\u20ac', u'\xa5', u'\u0160', u'\xa7', u'\u0161', u'\xa9', u'\xaa', u'\xab', u'\xac', u'\xad', u'\xae', u'\xaf', u'\xb0', u'\xb1', u'\xb2', u'\xb3', u'\u017d', u'\xb5', u'\xb6', u'\xb7', u'\u017e', u'\xb9', u'\xba', u'\xbb', u'\u0152', u'\u0153', u'\u0178', u'\xbf', u'\xc0', u' ']]
class KeyboardWindow(ConfirmWindow):
	type = 'keyboard'
	def __init__(self, title='', text='', buttons=None, confirm_action=None, alphabet='', special_chars=latin_map, columns=None, eventhandler=None):
		ConfirmWindow.__init__(self, text=text, buttons=[])
		self.title = title
		if not columns:
			columns = 12
		self.columns = columns
		if not buttons:
			buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
			buttons[0].connect(partial(self.change_special_char, -1))
			buttons[1].connect(self.change_special_char)
			buttons[2].connect(self.delete_char)
			if not confirm_action:
				pass
			buttons[3].connect(confirm_action, self)
			buttons[4].connect(self.hide)
		for but in buttons:
			but.type = 'action'
		self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
		self.special_char_list = []
		if not isinstance(special_chars, (list, tuple)):
			special_chars = [special_chars]
		for special_char in special_chars:
			self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
		self.special_chars = self.special_char_list[0]
		self.action_buttons = buttons
		self.button_ranges = [self.alphabet, self.special_chars, buttons]
		self._uppercase_mode = False
		self._text_cursor_pos = len(self.text)
		self._reset_selection()
		self.change_special_char(0)
		if not eventhandler:
			pass
		self.eventhandler = eventhandler

	def get_max_keys_number(self):
		sc_len = max(<genexpr>(self.special_char_list))
		return sc_len + len(self.alphabet)

	def _get_button_ranges(self):
		return self._button_ranges

	def _set_button_ranges(self, b_range):
		self._button_ranges = b_range

	button_ranges = property(_get_button_ranges, _set_button_ranges)
	del _get_button_ranges
	del _set_button_ranges
	def _KeyboardWindow__mk_text_button_list(self, char_string):
		ret = []
		for char in char_string:
			but = Button(char, False)
			but.connect(self.insert_char)
			ret.append(but)
		return ret

	def change_char_case(self):
		log.warning('Changing characters case is not supported anymore !')

	def change_special_char(self, sense=1):
		sense = max(-1, min(1, sense))
		chars_list = self.special_char_list
		actual_idx = chars_list.index(self.special_chars)
		old_list = chars_list[(actual_idx + sense - 1) % len(chars_list)]
		new_list = chars_list[(actual_idx + sense + 1) % len(chars_list)]
		if sense > 0 and self.special_chars == chars_list[-1]:
			self.special_chars = chars_list[0]
		else:
			if sense < 0 and self.special_chars == chars_list[0]:
				self.special_chars = chars_list[-1]
			else:
				self.special_chars = chars_list[actual_idx + sense]
		self.button_ranges = [self.alphabet, self.special_chars, self.action_buttons]
		self.action_buttons[0].name = ''.join(<genexpr>(old_list[:4])) + ' <'
		self.action_buttons[1].name = '> ' + ''.join(<genexpr>(new_list[:4]))

	def delete_char(self):
		if self._text_cursor_pos > 0:
			self.text = self.text[:self._text_cursor_pos - 1] + self.text[self._text_cursor_pos:]
			self._text_cursor_pos -= 1

	def insert_char(self):
		char = self.selected.name
		if self._text_cursor_pos > 0:
			self.text = self.text[:self._text_cursor_pos] + char + self.text[self._text_cursor_pos:]
		else:
			self.text = char + self.text[self._text_cursor_pos:]
		self._text_cursor_pos += 1



class SilentKeyboardWindow(KeyboardWindow):
	type = 'silent_keyboard'
	def __init__(self, buttons=None, alphabet='', special_chars=latin_map, insert_char_action=None, delete_char_action=None, columns=None, eventhandler=None):
		self._insert_char_action = insert_char_action
		self._delete_char_action = delete_char_action
		if not buttons:
			buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
			buttons[0].connect(partial(self.change_special_char, -1))
			buttons[1].connect(self.change_special_char)
			buttons[2].connect(self.delete_char)
			buttons[3].connect(self.hide)
		for but in buttons:
			but.type = 'action'
		if not eventhandler:
			pass
		KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
		return None

	def delete_char(self):
		if self._delete_char_action:
			self._delete_char_action()

	def insert_char(self):
		if self._insert_char_action:
			self._insert_char_action(self.selected.name)



class NumericKeyboardWindow(KeyboardWindow):
	type = 'numeric_keyboard'
	def __init__(self, title='Enter number:', value=0, confirm_action=None, columns=3):
		text = value
		if isinstance(value, int):
			text = str(value)
		else:
			if isinstance(value, (float, long)):
				text = '%.2f' % value
		buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
		buttons[0].connect(self.delete_char)
		if not confirm_action:
			pass
		buttons[1].connect(confirm_action, self)
		buttons[2].connect(self.hide)
		KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons)

	def _NumericKeyboardWindow__stripped_val(self):
		return self._text.replace(' ', '')

	def get_int(self):
		return int(self._NumericKeyboardWindow__stripped_val())

	def get_float(self):
		return float(self._NumericKeyboardWindow__stripped_val())



class SearchKeyboardWindow(KeyboardWindow):
	type = 'keyboard'
	def __init__(self, title='Search', text='', confirm_action=None, search_menu=None):
		KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, eventhandler=SearchKeyboardEventHandler(self))
		self.search_menu = search_menu

	def hide(self, hide_search_menu=False):
		KeyboardWindow.hide(self)
		if hide_search_menu:
			self.search_menu.hide()



class HexaKeyboardWindow(KeyboardWindow):
	type = 'hexa_keyboard'
	def __init__(self, title='Search', text='', confirm_action=None):
		buttons = [Button(_('Exit'), False), Button(_('Delete'), False), Button(_('OK'), True)]
		buttons[0].connect(self.hide)
		buttons[1].connect(self.delete_char)
		if not confirm_action:
			pass
		buttons[2].connect(confirm_action, self)
		alphabet = '0123456789ABCDEF'
		KeyboardWindow.__init__(self, title=title, text=text, buttons=buttons, alphabet=alphabet, special_chars=['', ''])



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7718d2c>}
from __future__ import absolute_import
__all__ = ['KeyboardWindow', 'NumericKeyboardWindow', 'SearchKeyboardWindow', 'HexaKeyboardWindow', 'SilentKeyboardWindow']
from .confirmwindow import ConfirmWindow
from .core import Button
from pygui.eventmanager.windows import KeyboardEventHandler, SearchKeyboardEventHandler, SilentKeyboardEventHandler
from peewee.debug import GET_LOGGER
from functools import partial
log = GET_LOGGER(__name__)
latin_map = [[u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u'[', u'\\', u']', u'^', u'_', u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u':', u';', u'<', u'=', u'>', u'?', u' '], [u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'{', u'|', u'}', u'~', u'@', u'!', u'"', u'#', u'$', u'%', u'&', u"'", u'(', u')', u'*', u'+', u',', u'-', u'.', u'/', u'`', u' '], [u'\xc1', u'\xc2', u'\xc3', u'\xc4', u'\xc5', u'\xc6', u'\xc7', u'\xc8', u'\xc9', u'\xca', u'\xcb', u'\xcc', u'\xcd', u'\xce', u'\xcf', u'\xd0', u'\xd1', u'\xd2', u'\xd3', u'\xd4', u'\xd5', u'\xd6', u'\xd7', u'\xd8', u'\xd9', u'\xda', u'\xdb', u'\xdc', u'\xdd', u'\xde', u'\xdf', u'\xe0', u'\xe1', u'\xe2', u'\xe3', u'\xe4', u'\xe5', u'\xe6', u'\xe7', u'\xe8', u'\xe9', u'\xea', u'\xeb', u'\xec', u'\xed', u'\xee', u'\xef', u'\xf0'], [u'\xf1', u'\xf2', u'\xf3', u'\xf4', u'\xf5', u'\xf6', u'\xf7', u'\xf8', u'\xf9', u'\xfa', u'\xfb', u'\xfc', u'\xfd', u'\xfe', u'\xff', u'\xa1', u'\xa2', u'\xa3', u'\u20ac', u'\xa5', u'\u0160', u'\xa7', u'\u0161', u'\xa9', u'\xaa', u'\xab', u'\xac', u'\xad', u'\xae', u'\xaf', u'\xb0', u'\xb1', u'\xb2', u'\xb3', u'\u017d', u'\xb5', u'\xb6', u'\xb7', u'\u017e', u'\xb9', u'\xba', u'\xbb', u'\u0152', u'\u0153', u'\u0178', u'\xbf', u'\xc0', u' ']]
class KeyboardWindow(ConfirmWindow):
	type = 'keyboard'
	def __init__(self, title='', text='', buttons=None, confirm_action=None, alphabet='', special_chars=latin_map, columns=None, eventhandler=None):
		ConfirmWindow.__init__(self, text=text, buttons=[])
		self.title = title
		if not columns:
			columns = 12
		self.columns = columns
		if not buttons:
			buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
			buttons[0].connect(partial(self.change_special_char, -1))
			buttons[1].connect(self.change_special_char)
			buttons[2].connect(self.delete_char)
			if not confirm_action:
				pass
			buttons[3].connect(confirm_action, self)
			buttons[4].connect(self.hide)
		for but in buttons:
			but.type = 'action'
		self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet)
		self.special_char_list = []
		if not isinstance(special_chars, (list, tuple)):
			special_chars = [special_chars]
		for special_char in special_chars:
			self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char))
		self.special_chars = self.special_char_list[0]
		self.action_buttons = buttons
		self.button_ranges = [self.alphabet, self.special_chars, buttons]
		self._uppercase_mode = False
		self._text_cursor_pos = len(self.text)
		self._reset_selection()
		self.change_special_char(0)
		if not eventhandler:
			pass
		self.eventhandler = eventhandler

	def get_max_keys_number(self):
		sc_len = max(<genexpr>(self.special_char_list))
		return sc_len + len(self.alphabet)

	def _get_button_ranges(self):
		return self._button_ranges

	def _set_button_ranges(self, b_range):
		self._button_ranges = b_range

	button_ranges = property(_get_button_ranges, _set_button_ranges)
	del _get_button_ranges
	del _set_button_ranges
	def _KeyboardWindow__mk_text_button_list(self, char_string):
		ret = []
		for char in char_string:
			but = Button(char, False)
			but.connect(self.insert_char)
			ret.append(but)
		return ret

	def change_char_case(self):
		log.warning('Changing characters case is not supported anymore !')

	def change_special_char(self, sense=1):
		sense = max(-1, min(1, sense))
		chars_list = self.special_char_list
		actual_idx = chars_list.index(self.special_chars)
		old_list = chars_list[(actual_idx + sense - 1) % len(chars_list)]
		new_list = chars_list[(actual_idx + sense + 1) % len(chars_list)]
		if sense > 0 and self.special_chars == chars_list[-1]:
			self.special_chars = chars_list[0]
		else:
			if sense < 0 and self.special_chars == chars_list[0]:
				self.special_chars = chars_list[-1]
			else:
				self.special_chars = chars_list[actual_idx + sense]
		self.button_ranges = [self.alphabet, self.special_chars, self.action_buttons]
		self.action_buttons[0].name = ''.join(<genexpr>(old_list[:4])) + ' <'
		self.action_buttons[1].name = '> ' + ''.join(<genexpr>(new_list[:4]))

	def delete_char(self):
		if self._text_cursor_pos > 0:
			self.text = self.text[:self._text_cursor_pos - 1] + self.text[self._text_cursor_pos:]
			self._text_cursor_pos -= 1

	def insert_char(self):
		char = self.selected.name
		if self._text_cursor_pos > 0:
			self.text = self.text[:self._text_cursor_pos] + char + self.text[self._text_cursor_pos:]
		else:
			self.text = char + self.text[self._text_cursor_pos:]
		self._text_cursor_pos += 1



class SilentKeyboardWindow(KeyboardWindow):
	type = 'silent_keyboard'
	def __init__(self, buttons=None, alphabet='', special_chars=latin_map, insert_char_action=None, delete_char_action=None, columns=None, eventhandler=None):
		self._insert_char_action = insert_char_action
		self._delete_char_action = delete_char_action
		if not buttons:
			buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)]
			buttons[0].connect(partial(self.change_special_char, -1))
			buttons[1].connect(self.change_special_char)
			buttons[2].connect(self.delete_char)
			buttons[3].connect(self.hide)
		for but in buttons:
			but.type = 'action'
		if not eventhandler:
			pass
		KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, eventhandler)
		return None

	def delete_char(self):
		if self._delete_char_action:
			self._delete_char_action()

	def insert_char(self):
		if self._insert_char_action:
			self._insert_char_action(self.selected.name)



class NumericKeyboardWindow(KeyboardWindow):
	type = 'numeric_keyboard'
	def __init__(self, title='Enter number:', value=0, confirm_action=None, columns=3):
		text = value
		if isinstance(value, int):
			text = str(value)
		else:
			if isinstance(value, (float, long)):
				text = '%.2f' % value
		buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)]
		buttons[0].connect(self.delete_char)
		if not confirm_action:
			pass
		buttons[1].connect(confirm_action, self)
		buttons[2].connect(self.hide)
		KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons)

	def _NumericKeyboardWindow__stripped_val(self):
		return self._text.replace(' ', '')

	def get_int(self):
		return int(self._NumericKeyboardWindow__stripped_val())

	def get_float(self):
		return float(self._NumericKeyboardWindow__stripped_val())



class SearchKeyboardWindow(KeyboardWindow):
	type = 'keyboard'
	def __init__(self, title='Search', text='', confirm_action=None, search_menu=None):
		KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, eventhandler=SearchKeyboardEventHandler(self))
		self.search_menu = search_menu

	def hide(self, hide_search_menu=False):
		KeyboardWindow.hide(self)
		if hide_search_menu:
			self.search_menu.hide()



class HexaKeyboardWindow(KeyboardWindow):
	type = 'hexa_keyboard'
	def __init__(self, title='Search', text='', confirm_action=None):
		buttons = [Button(_('Exit'), False), Button(_('Delete'), False), Button(_('OK'), True)]
		buttons[0].connect(self.hide)
		buttons[1].connect(self.delete_char)
		if not confirm_action:
			pass
		buttons[2].connect(confirm_action, self)
		alphabet = '0123456789ABCDEF'
		KeyboardWindow.__init__(self, title=title, text=text, buttons=buttons, alphabet=alphabet, special_chars=['', ''])



